<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const person = {
        firstName: "姓",
        lastName: "名",

        // 获取 fullName 属性
        get fullName() {
          return `${this.firstName} ${this.lastName}`;
        },

        // 设置 fullName 属性
        set fullName(value) {
          [this.firstName, this.lastName] = value.split(" ");
        },
      };

      // 获取 fullName
      console.log(person.fullName);

      // 设置 fullName
      person.fullName = "何 玉婷";
      console.log(person.firstName);
      console.log(person.lastName);
    </script>
  </body>
</html>
